package cn.hgj.entity;

import cn.hgj.enums.OrderStatus;
import jakarta.persistence.*;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Entity
@Table(name = "t_order")
@Data
public class Order {
    @Id
    @Column(name = "order_id", length = 32)
    private String orderId;

    @Column(name = "user_id", nullable = false, length = 32)
    private String userId;

    @Column(name = "product_id", nullable = false, length = 32)
    private String productId;

    @Column(name = "quantity", nullable = false)
    private Integer quantity;

    @Column(name = "amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal amount;

    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false, length = 20)
    private OrderStatus status;

    @Column(name = "payment_id", length = 64)
    private String paymentId;

    @Column(name = "payment_time")
    private LocalDateTime paymentTime;

    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime = LocalDateTime.now();

    @Column(name = "update_time", nullable = false)
    private LocalDateTime updateTime = LocalDateTime.now();

    @Version
    @Column(name = "version")
    private Integer version;

    // 订单备注
    @Column(name = "remark", length = 200)
    private String remark;

    // 发货信息
    @Column(name = "shipping_info", length = 500)
    private String shippingInfo;

    // 收货地址
    @Column(name = "delivery_address", length = 500)
    private String deliveryAddress;
}